package com.tianpengtech.front.mobile.common.util;


import java.util.Random;

/**
 * Created by ggd on 2017/4/24.
 * 生成访问key
 */
public class TokenUtil {

    public static String getToken(){
        return ToolMD5.encodeMD5Hex(getRandomString(10));
    }

    private static String getRandomString(int length) { //length表示生成字符串的长度
        String base = "abcd(t45lmno%^&*(p678fgh!@#$ijkqrs9";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }
}
